
package keul.planner.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * Die Einträge der durch Lüder bereitgestellten Tabellen müssen als
 * Objekte modellierbar sein;
 * Tabelle:cities -> City-Objekte
 * 
 * @author kev
 */
@Entity
@Table(name="cities")
public class City implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id                 
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    @OneToOne
    private State state;
    @OneToOne
    private County county;
    @Column(name="lat")
    private float latitude;
    @Column(name="lng")
    private float longitude;

    
    
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public County getCounty() {
        return county;
    }
    public void setCounty(County county) {
        this.county = county;
    }
    public State getState() {
        return state;
    }
    public void setState(State state) {
        this.state = state;
    }
    public float getLatitude() {
        return latitude;
    }
    public void setLatitude(float latitude) {
        this.latitude = latitude;
    }
    public float getLongitude() {
        return longitude;
    }
    public void setLongitude(float longitude) {
        this.longitude = longitude;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof City)) {
            return false;
        }
        City other = (City) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("kev.entities.location.City[ id=").append(id==null?"-1":id)
                    .append("," + "name=\"").append(name)
                    .append("\", county.name=\"").append(county)
                    //.append("\", state.name=\"").append(state.getName())
                    .append("\"," + "latitude=").append(latitude)
                    .append("," + "longitude=\"").append(longitude)
                .append(" ]");
        return sb.toString();
    }
    
    

}
